﻿Imports Frame7
Imports Base7
Imports Base7.Shared
Imports System.Data


Public Class FAF881
    Private Sub Me_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Public Overrides Sub MenuButton_Click(ByVal mty As MenuType)
        Select Case mty
            Case MenuType.Open
                Me.Open()

                Me.Init_Title()
                Me.Disp_Data()
                g10.BestFitColumns()
            Case MenuType.Print
                Print()
            Case Else
                MyBase.MenuButton_Click(mty)        '나머지는 기본기능에 맡긴다

        End Select

    End Sub

    Private Sub Init_Title()

        'Dim dSet As DataSet = Me.OpenDataSet("faf970_get_title")
        'If IsEmpty(dSet) Then
        '    MessageInfo("조회 할 Data가 없습니다")
        '    'g10.Init()
        '    Exit Sub
        'End If

     
        Dim frDt As Date = fr_dt.Text
        Dim toDt As Date = to_dt.Text


        Dim cnt As Integer = DateDiff(DateInterval.Day, frDt, toDt)

        Dim arr(1, 0) As String, colNm As String, inx As Integer = 0


        For i = 0 To cnt

            colNm = Format(DateAdd(DateInterval.Day, i, frDt), "yyyy-MM-dd")


            ReDim Preserve arr(1, inx)      'Array를 증가시킨다

            arr(0, inx) = colNm          'FieldName 으로 사용된다
            arr(1, inx) = (i + 1).ToString + "일"          'Title로 사용된다

            inx += 1
        Next

        g10.InsertArrayColumns(Nothing, arr, "plan_amt")

    End Sub

    Private Sub Disp_Data()
        Try
            'Master 부분


            'g10.GridColumn("plan_dt").IsMasterKey = True
            g10.GridColumn("div_cd").IsMasterKey = True
            g10.GridColumn("fund_cd").IsMasterKey = True
            g10.GridColumn("fund_nm").IsMasterKey = True
            g10.GridColumn("fund_ty").IsMasterKey = True
            g10.GridColumn("ty_nm").IsMasterKey = True
            g10.GridColumn("rmk").IsMasterKey = True

            '  g10.GridColumn("fund_cd").IsDetailKey = True
            g10.GridColumn("plan_dt").IsDetailKey = True
            g10.GridColumn("plan_amt").IsDetailData = True

            g10.Open()

        Catch ex As Exception
            MessageInfo(ex, "Disp_Data()")
        End Try
    End Sub

    Private Sub Print()
        Dim p As OpenParameters = New OpenParameters
        p.Add("@co_cd", co_cd.Text)
        p.Add("@div_cd", div_cd.Text)
        p.Add("@fr_dt", fr_dt.Text)
        p.Add("@to_dt", to_dt.Text)

        System7.ReportView.LoadView("FAF881", "", "faf881_Print", p) '출근대장

        ' If XtraTabControl1.SelectedTabPageIndex = 5 Then
        'FAF850.ReportView2.LoadView("FAF850", "", "faf950_print", p, CrystalReportViewer, True, 1, "sub1.rpt", "faf500_print_2", p2)

        'End If




    End Sub
End Class
